/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gestionDeStageDAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Labassi Amine
 */
public class MysqlConnect {

    Connection cnt = null ;
    String url = "jdbc:mysql://127.0.0.1/dbmacsi";
    String user = null ;
    String passwd = null ;

    /**
     * Constructeur MysqConnect
     * @param pUser
     * @param pPasswd
     */
    public MysqlConnect(String pUser, String pPasswd) {
        user = pUser ;
        passwd = pPasswd ;
    }

    /**
     *
     * @return cnt de type Connection
     * @throws ClassNotFoundException
     * @throws InstantiationException
     * @throws IllegalAccessException
     * @throws SQLException
     */
    public Connection connect () throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException{
        String nomDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
        Object newInstance = Class.forName(nomDriver).newInstance();
        cnt = (Connection) DriverManager.getConnection(url,user,passwd);
        return cnt ;
    }
}
